package com.shop.www.service;

import com.shop.www.daoX.UserDAO;
import com.shop.www.daoX.UserDAOImpl;
import com.shop.www.po.user;
import com.shop.www.view.ViewBaseServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

    @WebServlet("/update.do")
public class update extends ViewBaseServlet {
        private UserDAO userDAO = new UserDAOImpl();
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        String idstr = request.getParameter("id");
        String name = request.getParameter("name");
        String agestr = request.getParameter("age");
        Integer id = Integer.parseInt(idstr);
        Integer age = Integer.parseInt(agestr);
        userDAO.updateuser(new user(id,name,age));

        //服务器内部转发
        //super.processTemplate("index",request,response);
        //重定向
        response.sendRedirect("index");

    }
}
